package com.wkck.exception;

import com.wkck.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ProjectExceptionHandler {

    /**
     * 业务异常处理
     * @param baseException
     * @return
     */
    @ExceptionHandler(BaseException.class)
    public Result<String> baseExceptionHandler(BaseException baseException) {
        log.error("系统业务异常信息：{}",baseException.getMessage());
        return Result.error(baseException.getMessage());
    }

    /**
     * 未知异常处理
     * @param exception
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result<String> doException(Exception exception){
        exception.printStackTrace();
        return Result.error("系统异常，请联系管理员");
    }
}
